<?php

/**
 * @category   Ac
 * @package    Application_Model
 * @copyright  Orient Network Ltd
 * @license    Closed
 * @author     John Wilson Lee
 */
class Model_Todayspick extends Ac_Model
{

    protected static  $_collection = 'todayspick';

    /**
     *
     * @var array define the requirements for this model
     */
    protected static $_requirements = array(
        'ls'  => array('Array'), //Email
    );

    protected static $_transcript = array(
        '_id'  => '_id',
        'nm'   => 'name',
        'ca'   => 'category_id',
        'ls'   => 'listing_id',
   );

    public function __construct($data = array(), $config = array())
	{
        $config['collection'] = 'todayspick';
        self::ensureIndex(array('nm'));
        parent::__construct($data, $config);
    }
	
	public function __isset($name) {
        $val = self::__get($name);
        return!empty($val) ? true : parent::__isset($name);
    }
    
    public static function getSection()
    {
        return self::all()->sort(array('_id' => 1)); 
    }

    public function __get($name)
    {
        
        return parent::__get($name);
        
    }
    
    public static function getHomepage()
    {
        return self::all(array('nm' => 'Homepage'));
    }
    
    public static function getCategory($id)
    {
        return self::all(array('ca' => $id));
    }
}
